package siam.ui;

import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
/**
 * Class which represent force
 * @author Motassim Saad
 *
 */
public enum Force {

	HAUT("top.png",-1,0), BAS("bottom.png",1,0), DROITE("right.png",0,1), GAUCHE("left.png",0,-1);


	private String name;
	private Image img;
	private int dirI;
	private int dirJ;
	
	/**
	 * Force Constructor a force is represented by a name which allow to find his 
	 * @param name
	 * @param dirI represent the row move of force 
	 * @param dirJ represent the column move of force
	 */
	private Force(String name,int dirI,int dirJ) {
		this.name=name;
		this.dirI=dirI;
		this.dirJ=dirJ;
		try {
			this.img=ImageIO.read(new File("tmp/"+name));
		} catch (IOException e) {
			System.err.println("load picture "+getName()+" impossible");
			e.printStackTrace();
		}
	}
	
	public String getName() {
		return name;
	}
	public Image getImg() {
		return img;
	}
	
	/**
	 * Return the force opposite
	 * @return {@link Force}
	 */
	public Force getOpposite(){
		switch (this) {
		case HAUT:
			return BAS;

		case BAS:
			return HAUT;

		case GAUCHE:
			return DROITE;

		case DROITE:
			return GAUCHE;

		default:
			return null;
		}
	}

	public int getDirI() {
		return this.dirI;
	}
	
	public int getDirJ() {
		return dirJ;
	}
	

}
